<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>继承</title>
</head>
<body>
   <script>
      function Parent(options) {
        this.options = options
       }
       Parent.prototype.parentFn1=function (){
           console.log('ParentFn1')
       }
         
       function initExtendFn (Parent){
            // Parent的静态方法extendFn 方法
            Parent.extendFn = function(){
                // Parent 调用extendFn ,所以this指向 Patent,记录this（Parent）
               const Super = this
                // 创建构造函数
                const Kid = function Kid(options){
                   this.age = 30
                   this.options = options
                }
                 // Kid构造函数的原型继承Parent的原型
                 Kid.prototype = Object.create(Super.prototype)
                //  Kid的constructor为自己的构造函数
                 Kid.prototype.constructor = Kid
                return Kid
           }
       }
    //    向Parent添加静态方法extentFn()
       initExtendFn(Parent)
    //    调用Parent的静态方法extendFn()
       let Kid = Parent.extendFn()
      let kid = new Kid({
           name:'yc',
           home:'China'
       })
       console.log(kid)
   </script>
</body>
</html>